package com.itheima.homework9;

import java.util.HashMap;
import java.util.Set;

/*
按照要求，编写下面的代码： 《Map集合练习》

键盘录入一个串英语单词，统计每个单词出现的次数。

素材句子： 请复制下面的句子

study well and make progress every day .
 study well and progress every day .
 study hard and make progress every day

 */
public class Test4 {
    public static void main(String[] args) {
        HashMap<String,Integer> hs=new HashMap<>();
        String str="study well and make progress every day study well and progress every day study hard and make progress every day";
        String[] array=str.split(" ");
        for (int i = 0; i < array.length; i++) {
            if(hs.containsKey(array[i])){
                int count=0;
                count=hs.get(array[i]);
                count++;
                hs.put(array[i],count);

            } else {
                hs.put(array[i],1);
            }


        }
        Set<String> keys = hs.keySet();
        for (String key : keys) {
            int value=hs.get(key);
            System.out.println(key + "---" + value);
        }


    }
}
